﻿@{
    Layout = null;
}
@using CNKI.TPI.Web.Search.Model;
<script type="text/javascript">
    function disablesave() {
        $(".btn-warn-f").attr("disabled", "disabled");
    }
    function enablesave(str) {
        $(".btn-warn-f").removeAttr("disabled", "disabled");
    }
    function saveOption() {
        disablesave();
        var len = $('.wrapR-c-box-b-item ul input').size();
        if (len <= 0) {
            messageAlert('请添加需要保存的数据项！');
            enablesave();
            return;
        }
        var jsondata = [];
        $('.wrapR-c-box-b-item ul input').each(function (index) {
            var dataobj = {
                "ErrorInfoList": $.trim($(this).parent().text())
            }
            jsondata.push(dataobj);

        })
        var dataold = { "list": jsondata };
        $.ajax({
            type: "POST",
            url: "@Html.Raw(Url.Action("SaveErrorList", "Admin_Submit"))",
            contentType: "application/json",
            data: JSON.stringify(dataold),
            success: function (msg) {
                if (msg == "True") {
                    messageAlert("操作成功！");
                }
                else {
                    messageAlert("操作失败！");
                }
                enablesave();
            },
            error: function (e)
            { enablesave(); }
        })

    }
    function addItem() {
        var iteminfo = $("#iteminfo").val();
        if (iteminfo == "") {
            messageAlert("请录入要添加的内容！");
            return;
        }
        //过滤重复
        var m = 0;
        $('.wrapR-c-box-b-item ul input').each(function (index) {
            if ($.trim($(this).parent().text()) == $.trim(iteminfo)) {
                m = 1;
            }
        })
        if (m == 1)
        {
            messageAlert("存在重复数据，请修改！");
            return;
        }
        var listr = " <li class=\"f-ct\">  <label class=\"f-label block\" style=\"padding-left:5px\">" +
                      " <input type=\"checkbox\" class=\"f-checkbox\"  onclick=\"itemcheck(this)\" value='0' />" + iteminfo + "</label></li>";
        $(".wrapR-c-box-b-item ul").append(listr);
        $(".check_all").removeAttr("checked", "checked");
    }
    function del() {
        if ($(".wrapR-c-box-b-item ul input:checked").size() <= 0) {
            messageAlert("请选择要删除的记录！");
        }
        else {
            $(".wrapR-c-box-b-item ul input:checked").each(function () {
                $(this).parent().parent().remove();
            })
            $(".check_all").removeAttr("checked", "checked");
        }
    }
    function checkAll(e) {
        if ($(e).attr("checked") == "checked") {
            $(".wrapR-c-box-b-item ul input").each(function () {
                $(this).attr("checked", "checked");
            })
        }
        else {
            $(".wrapR-c-box-b-item ul input").each(function () {
                $(this).removeAttr("checked", "checked");
            })
        }
    }
    function itemcheck(e) {
        if ($(e).attr("checked") == "checked") {
            //循环遍历
            var m = 0;
            $(".wrapR-c-box-b-item ul input").each(function () {
                if ($(this).attr("checked") != "checked") {
                    m =1;
                }
            })
            if (m == 1) {
                $(".check_all").removeAttr("checked", "checked");
            }
            else {
                $(".check_all").attr("checked", "checked");
            }
        }
        else {
            $(".check_all").removeAttr("checked", "checked");
        }

    }


</script>
<div class="wrapR-c wrapR-c2" style="padding-top: 50px; padding-bottom: 20px">
    <div class="clearfix posr wrapR-c2-in">
        <div class="form form-h">
            <div class="f-gp">
                <div class="f-lb" style="width: 8em">
                    <label class="f-label" style="text-decoration: none; cursor: default; font-size: 14px">审核不通过原因：</label>
                </div>
                <div class="f-ct f-ml">
                    <span class="f-input-ap block">
                        <input type="text" class="f-text span4" name="iteminfo" id="iteminfo" maxlength="255">
                        <a class="btn btn-submit btn-warn-f" href="javascript:void(0);" onclick="addItem()">添加</a>
                    </span>
                </div>
            </div>
        </div>
        <div class="wrapR-c-box wrapR-c-l fl posr" style="overflow-y: visible; margin-left: 124px; margin-top: 20px; width: 314px">
            <div class="wrapR-c-box-t">不通过原因列表</div>
            <div class="wrapR-c-box-b-item" style="overflow-y: scroll; height: 380px; width: 314px">
                <ul>
                      @{
                          if (ViewBag.ErrorReason != null)
                        {
                            foreach (SYS_CMS_ERRORINFOCONFIG item in ViewBag.ErrorReason)
                            {
                               
                        <li class="f-ct">
                            <label class="f-label block" style="padding-left:5px">
                                <input type="checkbox" class="f-checkboxL" onclick="leftcheck(this)" value='@item.SysID' />@item.ErrorInfoList</label>

                        </li>
                            }
                        }

                    }

                </ul>
                <div class="f-ct wrapR-c-box-footer posa">
                    <label class="f-label ml10">
                        <input type="checkbox" class="check_all" onclick="checkAll(this)" />全选</label>
                    <a class="btn btn-s btn-warn-f fr" onclick="del()">删除</a>
                </div>

            </div>
            <div class="tc mt30" style="padding: 30px">
                <button class="btn btn-m btn-submit btn-warn-f" onclick="saveOption()">保存</button>
            </div>
        </div>
    </div>

</div>
<!-- wrapREnd -->
